package stuff;

import org.drools.event.process.ProcessCompletedEvent;
import org.drools.event.process.ProcessEventListener;
import org.drools.event.process.ProcessNodeLeftEvent;
import org.drools.event.process.ProcessNodeTriggeredEvent;
import org.drools.event.process.ProcessStartedEvent;
import org.drools.event.process.ProcessVariableChangedEvent;
import org.drools.runtime.StatefulKnowledgeSession;
import org.jbpm.workflow.instance.node.RuleSetNodeInstance;

public class RuleTaskBasedListener implements ProcessEventListener {

	@Override
	public void afterNodeLeft(ProcessNodeLeftEvent arg0) {}

	@Override
	public void afterNodeTriggered(ProcessNodeTriggeredEvent e) {
		if(e.getNodeInstance().getClass().equals(RuleSetNodeInstance.class)){
			((StatefulKnowledgeSession)e.getKnowledgeRuntime()).fireAllRules();
		}
	}

	@Override
	public void afterProcessCompleted(ProcessCompletedEvent arg0) {}

	@Override
	public void afterProcessStarted(ProcessStartedEvent arg0) {}

	@Override
	public void afterVariableChanged(ProcessVariableChangedEvent arg0) {}

	@Override
	public void beforeNodeLeft(ProcessNodeLeftEvent arg0) {}

	@Override
	public void beforeNodeTriggered(ProcessNodeTriggeredEvent arg0) {}

	@Override
	public void beforeProcessCompleted(ProcessCompletedEvent arg0) {}

	@Override
	public void beforeProcessStarted(ProcessStartedEvent arg0) {}

	@Override
	public void beforeVariableChanged(ProcessVariableChangedEvent arg0) {}

}
